package fudan.se.project.controller.conference.action;


import fudan.se.project.controller.request.OnlyIdPropertyRequest;
import fudan.se.project.controller.request.PostReplyRequest;
import fudan.se.project.controller.request.ReviewInfoSubmitRequest;
import fudan.se.project.service.advanced.conference.action.PcMemberActionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user/conference/pcmember")
public class PcMemberActionController {

    private final PcMemberActionService pcMemberActionService;

    @Autowired
    public PcMemberActionController(PcMemberActionService pcMemberActionService) {
        this.pcMemberActionService = pcMemberActionService;
    }

    @GetMapping("/papers")
    public ResponseEntity<?> getTasks(
            @RequestParam long id,
            @RequestParam boolean completed
    ) {

        return pcMemberActionService.getTasks(id, completed);
    }

    @GetMapping("/paper/reviewInfo")
    public ResponseEntity<?> getTask(
            @RequestParam long id
    ) {

        return pcMemberActionService.getTask(id);
    }

    @PostMapping("/reviewInfo/submit")
    public ResponseEntity<?> submitReviewInfo(@RequestBody @Validated ReviewInfoSubmitRequest request) {

        return pcMemberActionService.submitReviewInfo(request);
    }

    @PostMapping("/replyPost")
    public ResponseEntity<?> replyPost(@RequestBody @Validated PostReplyRequest request) {

        log.info("reply to post:" + request.getId());
        return pcMemberActionService.replyPost(request);
    }

    @PostMapping("/reviewInfo/confirm")
    public ResponseEntity<?> confirmReviewInfo(@RequestBody @Validated OnlyIdPropertyRequest request) {

        log.info("confirm reviewInfo:" + request.getId());
        return pcMemberActionService.confirmReviewInfo(request);
    }

    @PostMapping("/reviewInfo/revise")
    public ResponseEntity<?> reviseReviewInfo(@RequestBody @Validated ReviewInfoSubmitRequest request) {

        log.info("revise reviewInfo:" + request.getId());
        return pcMemberActionService.reviseReviewInfo(request);
    }

}
